clear-content .\userdetails.txt
ii .\userdetails.txt
wh -foregroundcolor "yellow"  "Please put user details and press enter to continue like below:
Alias;Fname;Lname;Name(Only input when Fname and Lname are not provided,otherwise leave it blank);ExternalEmailAddress"
read-host " "
foreach($item in get-content .\userdetails.txt){
	$alias = $item.split(";")[0]
	$FirstName = $item.split(";")[1]
	$LastName = $item.split(";")[2]
	$name = $item.split(";")[3]
	if($name -eq $null -or $name -eq ""){
		$name = $FirstName + " " + $LastName
	}
	$exadr = "SMTP:" + $item.split(";")[4]
	New-MailContact -ExternalEmailAddress $exadr -Name $name -Alias $alias -FirstName $FirstName -Initials '' -LastName $LastName
}
Get-ADObject -server $DC -Filter "ObjectClass -eq 'contact'" -SearchBase  "CN=Users,DC=domain,DC=internal"| % {move-adobject $_ -TargetPath "OU=xx,OU=x,DC=domain,DC=internal"}

<#
ACCess DENIED IF CREATE CONTACT WITH OU 

PS M:\> New-MailContact -ExternalEmailAddress 'SMTP:dhinsda81@gmail.com' -Name '
Amandeep Kaur' -Alias 'akaur' -FirstName 'Amandeep' -Initials '' -LastName 'Kaur
' -OrganizationalUnit 'domain.internal/External/Contacts'

Active Directory operation failed on RAINBOW.domain.internal. This error is not
 retriable. Additional information: Access is denied.
Active directory response: 00000005: SecErr: DSID-031521D0, problem 4003 (INSUF
F_ACCESS_RIGHTS), data 0
    + CategoryInfo          : NotSpecified: (0:Int32) [New-MailContact], ADOpe
   rationException
    + FullyQualifiedErrorId : D071D50E,Microsoft.Exchange.Management.Recipient
   Tasks.NewMailContact

#>